1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | 1 1 1 1 1 1 9 4 4 9 1 6652 1 428 1 91 1 209 1 366 1 1 174 174 263 263 263 174 174 89 2 1 62 62 224 62 1 12291 12276 15 473 471 2 1 4286 4286 1 1 1 3 1 2 4 4 4 1 3 3 3 3 1 11 11 11 11 11 11 9 2 1 1 1 1 1 1 1 1 1 1 1 1 20906 20906 20906 20906 20906 20906 20906 246799 246799 58 58 58 58 58 58 58 62 62 132 58 58 20906 20906 20976 1 6107 1 7312 7312 6107 7266 6107 6107 1 13 13 18 13 18 30 13 13 1 1 12747 12747 13622 13634 12747 12747 | 'use strict'; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; ;require.register("utils/ember_reopen", function (exports, require, module) { /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var _Ember = Ember, assert = _Ember.assert, warn = _Ember.warn, EXTEND_PROTOTYPES = _Ember.EXTEND_PROTOTYPES; var END_WITH_EACH_REGEX = /\.@each$/; var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; /** Merge the contents of two objects together into the first object. ```javascript Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'} var a = {first: 'Yehuda'}, b = {last: 'Katz'}; Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'} ``` @method merge @for Ember @param {Object} original The object to merge into @param {Object} updates The object to copy properties from @return {Object} */ Ember.merge = function (original, updates) { for (var prop in updates) { Iif (!updates.hasOwnProperty(prop)) { continue; } original[prop] = updates[prop]; } return original; }; /** Returns true if the passed value is null or undefined. This avoids errors from JSLint complaining about use of ==, which can be technically confusing. ```javascript Ember.isNone(); // true Ember.isNone(null); // true Ember.isNone(undefined); // true Ember.isNone(''); // false Ember.isNone([]); // false Ember.isNone(function() {}); // false ``` @method isNone @for Ember @param {Object} obj Value to test @return {Boolean} */ Ember.isNone = function (obj) { return obj === null || obj === undefined; }; /** Verifies that a value is `null` or an empty string, empty array, or empty function. Constrains the rules on `Ember.isNone` by returning false for empty string and empty arrays. ```javascript Ember.isEmpty(); // true Ember.isEmpty(null); // true Ember.isEmpty(undefined); // true Ember.isEmpty(''); // true Ember.isEmpty([]); // true Ember.isEmpty('Adam Hawkins'); // false Ember.isEmpty([0,1,2]); // false ``` @method isEmpty @for Ember @param {Object} obj Value to test @return {Boolean} */ Ember.isEmpty = function (obj) { return Ember.isNone(obj) || obj.length === 0 && typeof obj !== 'function' || (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && Ember.get(obj, 'length') === 0; }; /** A value is blank if it is empty or a whitespace string. ```javascript Ember.isBlank(); // true Ember.isBlank(null); // true Ember.isBlank(undefined); // true Ember.isBlank(''); // true Ember.isBlank([]); // true Ember.isBlank('\n\t'); // true Ember.isBlank(' '); // true Ember.isBlank({}); // false Ember.isBlank('\n\t Hello'); // false Ember.isBlank('Hello world'); // false Ember.isBlank([1,2,3]); // false ``` @method isBlank @for Ember @param {Object} obj Value to test @return {Boolean} */ Ember.isBlank = function (obj) { return Ember.isEmpty(obj) || typeof obj === 'string' && obj.match(/\S/) === null; }; /** * Calculates sum of two numbers * Use this function as a callback on <code>invoke</code> etc * * @method sum * @param {Number} a * @param {Number} b * @returns {Number} */ Ember.sum = function (a, b) { return a + b; }; /** * Execute passed callback * * @param {Function} callback * @returns {*} */ Ember.clb = function (callback) { return callback(); }; /** * */ Ember.RadioButton = Ember.Checkbox.extend({ tagName: "input", type: "radio", attributeBindings: ["type", "name", "value", "checked", "style", "disabled"], click: function click() { this.set("selection", this.$().val()); }, checked: function () { return this.get("value") === this.get("selection"); }.property('value', 'selection') }); /** * Set value to obj by path * Create nested objects if needed * Example: * <code> * var a = {b: {}}; * var path = 'b.c.d'; * var value = 1; * Em.setFullPath(a, path, value); // a = {b: {c: {d: 1}}} * </code> * * @param {object} obj * @param {string} path * @param {*} value */ Ember.setFullPath = function (obj, path, value) { var parts = path.split('.'), sub_path = ''; parts.forEach(function (_path, _index) { Em.assert('path parts can\'t be empty', _path.length); sub_path += '.' + _path; if (_index === parts.length - 1) { Em.set(obj, sub_path, value); return; } if (Em.isNone(Em.get(obj, sub_path))) { Em.set(obj, sub_path, {}); } }); }; /** * * @param {object} target * @param {string[]} propertyNames * @returns {{}} */ Ember.getProperties = function (target, propertyNames) { var ret = {}; for (var i = 0; i < propertyNames.length; i++) { ret[propertyNames[i]] = Em.get(target, propertyNames[i]); } return ret; }; Em.View.reopen({ /** * overwritten set method of Ember.View to avoid uncaught errors * when trying to set property of destroyed view */ set: function set(attr, value) { if (!this.get('isDestroyed') && !this.get('isDestroying')) { this._super(attr, value); } else { console.debug('Calling set on destroyed view'); } }, /** * overwritten setProperties method of Ember.View to avoid uncaught errors * when trying to set multiple properties of destroyed view */ setProperties: function setProperties(hash) { if (!this.get('isDestroyed') && !this.get('isDestroying')) { this._super(hash); } else { console.debug('Calling setProperties on destroyed view'); } }, attributeBindings: ['data-qa'] }); Ember._HandlebarsBoundView.reopen({ /** * overwritten set method of Ember._HandlebarsBoundView to avoid uncaught errors * when trying to set property of destroyed view */ render: function render(buffer) { Eif (!this.get('isDestroyed') && !this.get('isDestroying')) { this._super(buffer); } else { console.debug('Calling render on destroyed view'); } } }); Ember.TextField.reopen({ attributeBindings: ['readOnly'] }); Ember.TextArea.reopen({ attributeBindings: ['readonly'] }); /** * Simply converts query string to object. * * @param {string} queryString query string e.g. '?param1=value1¶m2=value2' * @return {object} converted object */ function parseQueryParams(queryString) { if (!queryString) { return {}; } return queryString.replace(/^\?/, '').split('&').map(decodeURIComponent).reduce(function (p, c) { var keyVal = c.split('='); p[keyVal[0]] = keyVal[1]; return p; }, {}); }; Ember.Route.reopen({ /** * When you move to a new route by pressing the back or forward button, change url manually, click on link with url defined in href, * call Router.transitionTo or Router.route this method is called. * This method unites unroutePath, navigateAway and exit events to handle Route leaving in one place. * Also unlike the exit event it is possible to stop transition inside this handler. * To proceed transition just call callback.. * * @param {Router} router * @param {Object|String} context context from transition or path from route * @param {callback} callback should be called to proceed transition */ exitRoute: function exitRoute(router, context, callback) { callback(); }, /** * Query Params serializer. This method should be used inside <code>serialize</code> method. * You need to specify `:query` dynamic sygment in your route's <code>route</code> attribute * e.g. Em.Route.extend({ route: '/login:query'}) and return result of this method. * This method will set <code>serializedQuery</code> property to specified controller by name. * For concrete example see `app/routes/main.js`. * * @example * queryParams: Em.Route.extend({ * route: '/queryDemo:query', * serialize: function(route, params) { * return this.serializeQueryParams(route, params, 'controllerNameToSetQueryObject'); * } * }); * // now when navigated to http://example.com/#/queryDemo?param1=value1¶m2=value2 * // App.router.get('controllerNameToSetQueryObject').get('serializedQuery') * // will return { param1: 'value1', param2: 'value2' } * * @param {Em.Router} router router instance passed to <code>serialize</code> method * @param {object} params dynamic segment passed to <code>seriazlie</code> * @param {string} controllerName name of the controller to set `serializedQuery` as result * @return {object} */ serializeQueryParams: function serializeQueryParams(router, params, controllerName) { var controller = router.get(controllerName); controller.set('serializedQuery', parseQueryParams(params ? params.query : '')); return params || { query: '' }; }, scrollTop: function scrollTop() { window.scrollTo(0, 0); } }); Ember.Router.reopen({ // reopen original transitionTo and route methods to add calling of exitRoute transitionTo: function transitionTo(router, context) { var self = this; var args = arguments; var transitionTo = self._super; var callback = function callback() { transitionTo.apply(self, args); }; if (!this.get('currentState.exitRoute')) { callback(); } else { this.get('currentState').exitRoute(this, context, callback); } }, route: function route(path) { var self = this; var args = arguments; var transitionTo = self._super; var callback = function callback() { self.get('location').setURL(path); transitionTo.apply(self, args); }; var realPath; Iif (!this.get('currentState.exitRoute')) { callback(); } else { realPath = this.get('currentState').absoluteRoute(this); this.get('location').setURL(realPath); this.get('currentState').exitRoute(this, path, callback); } } }); function expandProperties(pattern, callback) { assert('A computed property key must be a string', typeof pattern === 'string'); assert('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1); var unbalancedNestedError = 'Brace expanded properties have to be balanced and cannot be nested, pattern: ' + pattern; var properties = [pattern]; // Iterating backward over the pattern makes dealing with indices easier. var bookmark = void 0; var inside = false; for (var i = pattern.length; i > 0; --i) { var current = pattern[i - 1]; switch (current) { // Closing curly brace will be the first character of the brace expansion we encounter. // Bookmark its index so long as we're not already inside a brace expansion. case '}': Eif (!inside) { bookmark = i - 1; inside = true; } else { assert(unbalancedNestedError, false); } break; // Opening curly brace will be the last character of the brace expansion we encounter. // Apply the brace expansion so long as we've already seen a closing curly brace. case '{': Eif (inside) { var expansion = pattern.slice(i, bookmark).split(','); // Iterating backward allows us to push new properties w/out affecting our "cursor". for (var j = properties.length; j > 0; --j) { // Extract the unexpanded property from the array. var property = properties.splice(j - 1, 1)[0]; // Iterate over the expansion, pushing the newly formed properties onto the array. for (var k = 0; k < expansion.length; ++k) { properties.push(property.slice(0, i - 1) + expansion[k] + property.slice(bookmark + 1)); } } inside = false; } else { assert(unbalancedNestedError, false); } break; } } Iif (inside) { assert(unbalancedNestedError, false); } for (var _i = 0; _i < properties.length; _i++) { callback(properties[_i].replace(END_WITH_EACH_REGEX, '.[]')); } } Ember.ComputedProperty.prototype.property = function () { var args = []; function addArg(property) { warn('Dependent keys containing @each only work one level deep. ' + ('You used the key "' + property + '" which is invalid. ') + 'Please create an intermediary computed property.', DEEP_EACH_REGEX.test(property) === false); args.push(property); } for (var i = 0; i < arguments.length; i++) { expandProperties(arguments[i], addArg); } this._dependentKeys = args.uniq(); return this; }; Ember.observer = function (func) { var args = []; for (var _len = arguments.length, paths = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { paths[_key - 1] = arguments[_key]; } for (var i = 0; i < paths.length; i++) { expandProperties(paths[i], function (property) { return args.push(property); }); } func.__ember_observes__ = args.uniq(); return func; }; Eif (EXTEND_PROTOTYPES) { Function.prototype.observes = function () { var args = []; for (var i = 0; i < arguments.length; i++) { expandProperties(arguments[i], function (property) { return args.push(property); }); } this.__ember_observes__ = args.uniq(); return this; }; } }); |