mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 22:47:59 +01:00
Upgraded to Angular 1.3.20.
This commit is contained in:
parent
f563c7426f
commit
4e0eea71e4
4 changed files with 4021 additions and 6026 deletions
|
@ -219,7 +219,7 @@ gulp.task('build', [
|
||||||
'styles-embed'
|
'styles-embed'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
gulp.task("watch", function () {
|
gulp.task("watch", ["build"], function () {
|
||||||
plug.livereload.listen();
|
plug.livereload.listen();
|
||||||
gulp.watch("resources/assets/scripts/**/*.{coffee,js}", ["scripts-app"]);
|
gulp.watch("resources/assets/scripts/**/*.{coffee,js}", ["scripts-app"]);
|
||||||
gulp.watch("resources/assets/styles/**/*.{css,less}", ["styles-app"]);
|
gulp.watch("resources/assets/styles/**/*.{css,less}", ["styles-app"]);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "pony.fm",
|
"name": "pony.fm",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
"license": "AGPL",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://git@phabricator.poniverse.net/diffusion/PF/pony-fm.git"
|
"url": "ssh://git@phabricator.poniverse.net/diffusion/PF/pony-fm.git"
|
||||||
|
|
9732
resources/assets/scripts/base/angular.js
vendored
9732
resources/assets/scripts/base/angular.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,57 +1,88 @@
|
||||||
'use strict';
|
(function () {
|
||||||
/**
|
"use strict";
|
||||||
* Bindonce - Zero watches binding for AngularJs
|
/**
|
||||||
* @version v0.1.1 - 2013-05-07
|
* Bindonce - Zero watches binding for AngularJs
|
||||||
* @link https://github.com/Pasvaz/bindonce
|
* @version v0.3.3
|
||||||
* @author Pasquale Vazzana <pasqualevazzana@gmail.com>
|
* @link https://github.com/Pasvaz/bindonce
|
||||||
* @license MIT License, http://www.opensource.org/licenses/MIT
|
* @author Pasquale Vazzana <pasqualevazzana@gmail.com>
|
||||||
*/
|
* @license MIT License, http://www.opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
angular.module('pasvaz.bindonce', [])
|
var bindonceModule = angular.module('pasvaz.bindonce', []);
|
||||||
|
|
||||||
.directive('bindonce', function() {
|
bindonceModule.directive('bindonce', function ()
|
||||||
var toBoolean = function(value) {
|
{
|
||||||
if (value && value.length !== 0) {
|
var toBoolean = function (value)
|
||||||
|
{
|
||||||
|
if (value && value.length !== 0)
|
||||||
|
{
|
||||||
var v = angular.lowercase("" + value);
|
var v = angular.lowercase("" + value);
|
||||||
value = !(v == 'f' || v == '0' || v == 'false' || v == 'no' || v == 'n' || v == '[]');
|
value = !(v === 'f' || v === '0' || v === 'false' || v === 'no' || v === 'n' || v === '[]');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
value = false;
|
value = false;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
var msie = parseInt((/msie (\d+)/.exec(angular.lowercase(navigator.userAgent)) || [])[1], 10);
|
||||||
|
if (isNaN(msie))
|
||||||
|
{
|
||||||
|
msie = parseInt((/trident\/.*; rv:(\d+)/.exec(angular.lowercase(navigator.userAgent)) || [])[1], 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
var bindonceDirective =
|
||||||
|
{
|
||||||
restrict: "AM",
|
restrict: "AM",
|
||||||
controller: ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {
|
controller: ['$scope', '$element', '$attrs', '$interpolate', function ($scope, $element, $attrs, $interpolate)
|
||||||
var showHideBinder = function(elm, attr, value)
|
{
|
||||||
|
var showHideBinder = function (elm, attr, value)
|
||||||
{
|
{
|
||||||
var show = (attr == 'show') ? '' : 'none';
|
var show = (attr === 'show') ? '' : 'none';
|
||||||
var hide = (attr == 'hide') ? '' : 'none';
|
var hide = (attr === 'hide') ? '' : 'none';
|
||||||
elm.css('display', toBoolean(value) ? show : hide);
|
elm.css('display', toBoolean(value) ? show : hide);
|
||||||
}
|
};
|
||||||
var classBinder = function(elm, value)
|
var classBinder = function (elm, value)
|
||||||
{
|
{
|
||||||
if (angular.isObject(value) && !angular.isArray(value)) {
|
if (angular.isObject(value) && !angular.isArray(value))
|
||||||
|
{
|
||||||
var results = [];
|
var results = [];
|
||||||
angular.forEach(value, function(value, index) {
|
angular.forEach(value, function (value, index)
|
||||||
|
{
|
||||||
if (value) results.push(index);
|
if (value) results.push(index);
|
||||||
});
|
});
|
||||||
value = results;
|
value = results;
|
||||||
}
|
}
|
||||||
if (value) {
|
if (value)
|
||||||
|
{
|
||||||
elm.addClass(angular.isArray(value) ? value.join(' ') : value);
|
elm.addClass(angular.isArray(value) ? value.join(' ') : value);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
var transclude = function (transcluder, scope)
|
||||||
|
{
|
||||||
|
transcluder.transclude(scope, function (clone)
|
||||||
|
{
|
||||||
|
var parent = transcluder.element.parent();
|
||||||
|
var afterNode = transcluder.element && transcluder.element[transcluder.element.length - 1];
|
||||||
|
var parentNode = parent && parent[0] || afterNode && afterNode.parentNode;
|
||||||
|
var afterNextSibling = (afterNode && afterNode.nextSibling) || null;
|
||||||
|
angular.forEach(clone, function (node)
|
||||||
|
{
|
||||||
|
parentNode.insertBefore(node, afterNextSibling);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var ctrl =
|
var ctrl =
|
||||||
{
|
{
|
||||||
watcherRemover : undefined,
|
watcherRemover: undefined,
|
||||||
binders : [],
|
binders: [],
|
||||||
group : $attrs.boName,
|
group: $attrs.boName,
|
||||||
element : $element,
|
element: $element,
|
||||||
ran : false,
|
ran: false,
|
||||||
|
|
||||||
addBinder : function(binder)
|
addBinder: function (binder)
|
||||||
{
|
{
|
||||||
this.binders.push(binder);
|
this.binders.push(binder);
|
||||||
|
|
||||||
|
@ -64,35 +95,80 @@ angular.module('pasvaz.bindonce', [])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setupWatcher : function(bindonceValue)
|
setupWatcher: function (bindonceValue)
|
||||||
{
|
{
|
||||||
var that = this;
|
var that = this;
|
||||||
this.watcherRemover = $scope.$watch(bindonceValue, function(newValue)
|
this.watcherRemover = $scope.$watch(bindonceValue, function (newValue)
|
||||||
{
|
{
|
||||||
if (newValue == undefined) return;
|
if (newValue === undefined) return;
|
||||||
that.removeWatcher();
|
that.removeWatcher();
|
||||||
that.runBinders();
|
that.checkBindonce(newValue);
|
||||||
}, true);
|
}, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeWatcher : function()
|
checkBindonce: function (value)
|
||||||
{
|
{
|
||||||
if (this.watcherRemover != undefined)
|
var that = this, promise = (value.$promise) ? value.$promise.then : value.then;
|
||||||
|
// since Angular 1.2 promises are no longer
|
||||||
|
// undefined until they don't get resolved
|
||||||
|
if (typeof promise === 'function')
|
||||||
|
{
|
||||||
|
promise(function ()
|
||||||
|
{
|
||||||
|
that.runBinders();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
that.runBinders();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeWatcher: function ()
|
||||||
|
{
|
||||||
|
if (this.watcherRemover !== undefined)
|
||||||
{
|
{
|
||||||
this.watcherRemover();
|
this.watcherRemover();
|
||||||
this.watcherRemover = undefined;
|
this.watcherRemover = undefined;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
runBinders : function()
|
runBinders: function ()
|
||||||
{
|
{
|
||||||
for (var data in this.binders)
|
while (this.binders.length > 0)
|
||||||
{
|
{
|
||||||
var binder = this.binders[data];
|
var binder = this.binders.shift();
|
||||||
if (this.group && this.group != binder.group ) continue;
|
if (this.group && this.group != binder.group) continue;
|
||||||
var value = $scope.$eval(binder.value);
|
var value = binder.scope.$eval((binder.interpolate) ? $interpolate(binder.value) : binder.value);
|
||||||
switch(binder.attr)
|
switch (binder.attr)
|
||||||
{
|
{
|
||||||
|
case 'boIf':
|
||||||
|
if (toBoolean(value))
|
||||||
|
{
|
||||||
|
transclude(binder, binder.scope.$new());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'boSwitch':
|
||||||
|
var selectedTranscludes, switchCtrl = binder.controller[0];
|
||||||
|
if ((selectedTranscludes = switchCtrl.cases['!' + value] || switchCtrl.cases['?']))
|
||||||
|
{
|
||||||
|
binder.scope.$eval(binder.attrs.change);
|
||||||
|
angular.forEach(selectedTranscludes, function (selectedTransclude)
|
||||||
|
{
|
||||||
|
transclude(selectedTransclude, binder.scope.$new());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'boSwitchWhen':
|
||||||
|
var ctrl = binder.controller[0];
|
||||||
|
ctrl.cases['!' + binder.attrs.boSwitchWhen] = (ctrl.cases['!' + binder.attrs.boSwitchWhen] || []);
|
||||||
|
ctrl.cases['!' + binder.attrs.boSwitchWhen].push({ transclude: binder.transclude, element: binder.element });
|
||||||
|
break;
|
||||||
|
case 'boSwitchDefault':
|
||||||
|
var ctrl = binder.controller[0];
|
||||||
|
ctrl.cases['?'] = (ctrl.cases['?'] || []);
|
||||||
|
ctrl.cases['?'].push({ transclude: binder.transclude, element: binder.element });
|
||||||
|
break;
|
||||||
case 'hide':
|
case 'hide':
|
||||||
case 'show':
|
case 'show':
|
||||||
showHideBinder(binder.element, binder.attr, value);
|
showHideBinder(binder.element, binder.attr, value);
|
||||||
|
@ -106,30 +182,50 @@ angular.module('pasvaz.bindonce', [])
|
||||||
case 'html':
|
case 'html':
|
||||||
binder.element.html(value);
|
binder.element.html(value);
|
||||||
break;
|
break;
|
||||||
|
case 'style':
|
||||||
|
binder.element.css(value);
|
||||||
|
break;
|
||||||
|
case 'disabled':
|
||||||
|
binder.element.prop('disabled', value);
|
||||||
|
break;
|
||||||
case 'src':
|
case 'src':
|
||||||
|
binder.element.attr(binder.attr, value);
|
||||||
|
if (msie) binder.element.prop('src', value);
|
||||||
|
break;
|
||||||
|
case 'attr':
|
||||||
|
angular.forEach(binder.attrs, function (attrValue, attrKey)
|
||||||
|
{
|
||||||
|
var newAttr, newValue;
|
||||||
|
if (attrKey.match(/^boAttr./) && binder.attrs[attrKey])
|
||||||
|
{
|
||||||
|
newAttr = attrKey.replace(/^boAttr/, '').replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
||||||
|
newValue = binder.scope.$eval(binder.attrs[attrKey]);
|
||||||
|
binder.element.attr(newAttr, newValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
case 'href':
|
case 'href':
|
||||||
case 'alt':
|
case 'alt':
|
||||||
case 'title':
|
case 'title':
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'style':
|
|
||||||
case 'value':
|
case 'value':
|
||||||
binder.element.attr(binder.attr, value);
|
binder.element.attr(binder.attr, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.ran = true;
|
this.ran = true;
|
||||||
this.binders = [];
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return ctrl;
|
angular.extend(this, ctrl);
|
||||||
}],
|
}],
|
||||||
|
|
||||||
link: function(scope, elm, attrs, bindonceController) {
|
link: function (scope, elm, attrs, bindonceController)
|
||||||
var value = (attrs.bindonce) ? scope.$eval(attrs.bindonce) : true;
|
{
|
||||||
if (value != undefined)
|
var value = attrs.bindonce && scope.$eval(attrs.bindonce);
|
||||||
|
if (value !== undefined)
|
||||||
{
|
{
|
||||||
bindonceController.runBinders();
|
bindonceController.checkBindonce(value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -138,56 +234,92 @@ angular.module('pasvaz.bindonce', [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return bindonceDirective;
|
||||||
});
|
});
|
||||||
|
|
||||||
angular.forEach({
|
angular.forEach(
|
||||||
'boShow' : 'show',
|
[
|
||||||
'boHide' : 'hide',
|
{ directiveName: 'boShow', attribute: 'show' },
|
||||||
'boClass' : 'class',
|
{ directiveName: 'boHide', attribute: 'hide' },
|
||||||
'boText' : 'text',
|
{ directiveName: 'boClass', attribute: 'class' },
|
||||||
'boHtml' : 'html',
|
{ directiveName: 'boText', attribute: 'text' },
|
||||||
'boSrc' : 'src',
|
{ directiveName: 'boBind', attribute: 'text' },
|
||||||
'boHref' : 'href',
|
{ directiveName: 'boHtml', attribute: 'html' },
|
||||||
'boAlt' : 'alt',
|
{ directiveName: 'boSrcI', attribute: 'src', interpolate: true },
|
||||||
'boTitle' : 'title',
|
{ directiveName: 'boSrc', attribute: 'src' },
|
||||||
'boId' : 'id',
|
{ directiveName: 'boHrefI', attribute: 'href', interpolate: true },
|
||||||
'boStyle' : 'style',
|
{ directiveName: 'boHref', attribute: 'href' },
|
||||||
'boValue' : 'value'
|
{ directiveName: 'boAlt', attribute: 'alt' },
|
||||||
},
|
{ directiveName: 'boTitle', attribute: 'title' },
|
||||||
function(tag, attribute)
|
{ directiveName: 'boId', attribute: 'id' },
|
||||||
|
{ directiveName: 'boStyle', attribute: 'style' },
|
||||||
|
{ directiveName: 'boDisabled', attribute: 'disabled' },
|
||||||
|
{ directiveName: 'boValue', attribute: 'value' },
|
||||||
|
{ directiveName: 'boAttr', attribute: 'attr' },
|
||||||
|
|
||||||
|
{ directiveName: 'boIf', transclude: 'element', terminal: true, priority: 1000 },
|
||||||
|
{ directiveName: 'boSwitch', require: 'boSwitch', controller: function () { this.cases = {}; } },
|
||||||
|
{ directiveName: 'boSwitchWhen', transclude: 'element', priority: 800, require: '^boSwitch' },
|
||||||
|
{ directiveName: 'boSwitchDefault', transclude: 'element', priority: 800, require: '^boSwitch' }
|
||||||
|
],
|
||||||
|
function (boDirective)
|
||||||
{
|
{
|
||||||
var childPriority = 200;
|
var childPriority = 200;
|
||||||
return angular.module('pasvaz.bindonce').directive(attribute, function()
|
return bindonceModule.directive(boDirective.directiveName, function ()
|
||||||
{
|
{
|
||||||
return {
|
var bindonceDirective =
|
||||||
priority: childPriority,
|
{
|
||||||
require: '^bindonce',
|
priority: boDirective.priority || childPriority,
|
||||||
link: function(scope, elm, attrs, bindonceController)
|
transclude: boDirective.transclude || false,
|
||||||
|
terminal: boDirective.terminal || false,
|
||||||
|
require: ['^bindonce'].concat(boDirective.require || []),
|
||||||
|
controller: boDirective.controller,
|
||||||
|
compile: function (tElement, tAttrs, transclude)
|
||||||
{
|
{
|
||||||
var name = attrs.boParent;
|
return function (scope, elm, attrs, controllers)
|
||||||
if (name && bindonceController.group != name)
|
|
||||||
{
|
{
|
||||||
var element = bindonceController.element.parent();
|
var bindonceController = controllers[0];
|
||||||
bindonceController = undefined;
|
var name = attrs.boParent;
|
||||||
var parentValue;
|
if (name && bindonceController.group !== name)
|
||||||
|
{
|
||||||
|
var element = bindonceController.element.parent();
|
||||||
|
bindonceController = undefined;
|
||||||
|
var parentValue;
|
||||||
|
|
||||||
while (element[0].nodeType != 9 && element.length)
|
while (element[0].nodeType !== 9 && element.length)
|
||||||
{
|
|
||||||
if ((parentValue = element.data('$bindonceController'))
|
|
||||||
&& parentValue.group == name)
|
|
||||||
{
|
{
|
||||||
bindonceController = parentValue
|
if ((parentValue = element.data('$bindonceController'))
|
||||||
break;
|
&& parentValue.group === name)
|
||||||
|
{
|
||||||
|
bindonceController = parentValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
element = element.parent();
|
||||||
|
}
|
||||||
|
if (!bindonceController)
|
||||||
|
{
|
||||||
|
throw new Error("No bindonce controller: " + name);
|
||||||
}
|
}
|
||||||
element = element.parent();
|
|
||||||
}
|
}
|
||||||
if (!bindonceController)
|
|
||||||
|
bindonceController.addBinder(
|
||||||
{
|
{
|
||||||
throw Error("No bindonce controller: " + name);
|
element: elm,
|
||||||
}
|
attr: boDirective.attribute || boDirective.directiveName,
|
||||||
}
|
attrs: attrs,
|
||||||
bindonceController.addBinder({element: elm, attr:tag, value: attrs[attribute], group: name});
|
value: attrs[boDirective.directiveName],
|
||||||
|
interpolate: boDirective.interpolate,
|
||||||
|
group: name,
|
||||||
|
transclude: transclude,
|
||||||
|
controller: controllers.slice(1),
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
return bindonceDirective;
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
})();
|
||||||
|
|
Loading…
Reference in a new issue