Rename bindonce to bind.

stable
Andrey Antukh 2014-07-01 13:17:04 +02:00
parent 06902994af
commit 7196c5406c
1 changed files with 21 additions and 11 deletions

View File

@ -16,26 +16,36 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# File: modules/base/bindonce.coffee # File: modules/base/bind.coffee
### ###
bindOnce = @.taiga.bindOnce bindOnce = @.taiga.bindOnce
# Html bind once directive # Html bind once directive
BindHtmlDirective = -> BindOnceHtmlDirective = ->
link = (scope, element, attrs) -> link = ($scope, $el, $attrs) ->
bindOnce scope, attrs.tgBoHtml, (val) -> bindOnce $scope, $attrs.tgBoHtml, (val) ->
element.html(val) $el.html(val)
return {link:link} return {link:link}
# Object reference bind once helper. # Object reference bind once helper.
BindRefDirective = -> BindOnceRefDirective = ->
link = (scope, element, attrs) -> link = ($scope, $el, $attrs) ->
bindOnce scope, attrs.tgBoRef, (val) -> bindOnce $scope, $attrs.tgBoRef, (val) ->
element.html("##{val} ") $el.html("##{val} ")
return {link:link} return {link:link}
BindHtmlDirective = ->
link = ($scope, $el, $attrs) ->
$scope.$watch $attrs.tgBindHtml, (val) ->
$el.html(val) if val
return {link:link}
module = angular.module("taigaBase") module = angular.module("taigaBase")
module.directive("tgBoHtml", BindHtmlDirective) module.directive("tgBoHtml", BindOnceHtmlDirective)
module.directive("tgBoRef", BindRefDirective) module.directive("tgBoRef", BindOnceRefDirective)
module.directive("tgBindHtml", BindHtmlDirective)